<extend name="Public/base" />
<block name="content">
<script src="__JS__/jjhh.js?v={:C('TKE_VERSION')}"></script>
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a class="tip-bottom" href="{:U('Index/index')}" data-original-title="首页"><i class="icon-home"></i> 首页</a>
			<a class="tip-bottom" href="{:U('activitySet?activity_id='.I('activity_id'))}" data-original-title="">{$meta_title_c}</a> 
			<a class="current" href="{$post_url}">{$meta_title}</a>
		</div>
	</div>
    <div class="container-fluid" style="margin-top:15px;">
        <!-- 活动信息 -->
        <div class="row-fluid">

            <form method="post">        
                <h4>{$meta_title}</h4>
                <!-- 地区选择 -->
                <div class="pull-left">
                	<input type="hidden" name="activity_id" id="activity_id" value="{$activity_id}"/>
                    <!-- 地区选择 -->
                    <div class="u-select-area" id="j-select-area">
                        <select name="province" style="width:150px;display:none;"  id="j-select-province">
                            <option value="0">请选择省</option>
                        </select>
                        <select name="city" style="width:150px;display:none;" disabled  id="j-select-city">
                            <option value="0">请选择城市</option>
                        </select>
                        <select name="ward" style="width:150px;display:none;" disabled  id="j-select-ward">
                            <option value="0">请选择区</option>
                        </select>
                    </div>
                    <!-- /地区选择 -->
                </div>    
                <!-- /地区选择 -->
                <a id="j-btn-get-list" class="btn btn-small pull-left" style="margin:1px 0 0 15px;"> <i class="icon-search"></i> 确定</a>

                <script type="text/javascript">
                var URL_GET_LIST = "{:U('ServiceManage/getSalePointList')}";

                $("#j-btn-get-list").click(function() {
                    var province = $("#j-select-province").val();
                    var city     = $("#j-select-city").val();
                    var ward     = $("#j-select-ward").val();
                    var village  = $("#j-select-village").val();
                    var activity_id = $("#activity_id").val();

                    var d = dialog({"title": "请等待..."}).showModal();
                    $.ajax({
                        "url": URL_GET_LIST,
                        "type": "GET",
                        "dataType": "json",
                        "data": {"province": province, "city": city, "ward": ward, "village": village,"activity_id":activity_id},
                    }).done(function(json) {
                        d.remove().close();
                        if(1 == json.status){
                            var key  = json.key;
                            var html_row_all = "";
                            var html_row_th  = "<tr><th class=\"taskStatus\"><input type=\"checkbox\"></th>"
                            var html_row_td  = "";
                            var data = json.data;
                            var p_id = json.primary_value;
                            var p_name = json.primary_key;

                            for(k in key){
                                html_row_th+= "<th class=\"taskStatus\">" + json.key_name[k] + "</th>";
                            }
                            html_row_th+= "</tr>";

                            for( k in data ){
                                html_row_td+= "<tr><td class=\"taskStatus\"><input name=" + p_name + "[] value=" + p_id[k] + " type=\"checkbox\"></td>";
                                for(k2 in key){
                                    html_row_td+= "<td class=\"taskStatus\">" + data[k][key[k2]] + "</td>";
                                }
                                html_row_td+= "</tr>";
                            }
                            html_row_all = html_row_th + html_row_td;
                            $("#j-table").html(html_row_all);
                        }else{
                            dialog({
                                "title": "提示",
                                "content": json.info
                            }).showModal();
                        }
                        $("th").children("input").click(function() {
                            $("td>input[type=checkbox]").prop("checked", $(this).is(":checked"));
                        })
                    })
                });
                </script>    

                <div class="clearfix"></div>
                <br/>
                <p align="center" class="muted">点击确定获取数据</p> 
                
                <div class="data-list">
                    <table id="j-table" class="table table-bordered table-striped" style="margin-top:15px;">
                        <tr>
                            <th><input type="checkbox"></th>
                            <th>销售网点序号</th>
                            <th>销售网点名称</th>
                        </tr>
                    </table>  
                    <button type="submit" class="btn btn-primary"><i class="icon-ok"></i> 提交</button>
                </div>

            </form>
        </div>
    </div>
</div>
<script src="__STATIC__/aui-artDialog-9fd667e/dist/dialog.js"></script>
<link rel="stylesheet" href="__STATIC__/aui-artDialog-9fd667e/css/ui-dialog.css">
<script type="text/javascript">
$(function() {
    var url_area = {
   		 "province" :"{:U('ServiceApi/getProvinceList')}",
         "city" :"{:U('ServiceApi/getProvinceCityList')}",
         "ward": "{:U('ServiceApi/getCityWard')}",
         "village": "{:U('ServiceApi/getWardVillage')}"
   }
   jjhh_select_area(url_area, 3);                                	
})

$(document).ready(function(){
	//初始化登录用户名输入焦点
	tke_form_focus();
	$("form").submit(function(){
		//锁定登录按钮
		$('button').attr('disabled',true);
		var self = $(this);
		$.post("{$post_url}", self.serialize(), call_back, "json");
		return false;
		
		/**
		 * @todo 接收登录返回值
		 * @author PHP@妖孽 <dino_ma@163.com>
		 */
		function call_back(data){
			if(data.status==1){
				tke_alert(data.info,'alert-success');
				setTimeout(function(){
				  if (data.url) {
						location.href=data.url;
					}else{
						location.reload();
					}
				},1500);
			} else {
				$('button').attr('disabled',false);
				tke_alert(data.info,'alert-error');
			}
		}
	});
	//导航高亮
	highlight_subnav("{:U('ServiceManage/index')}");
});
</script>
</block>